﻿using System;

using Cookbook.Services.Core.Commands;
using Cookbook.Services.Core.Domain;

using Cooking.Services.Specs.Builders;
using Cooking.Services.Specs.Support;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Cooking.Services.Specs.Commanding
{
    [TestClass]
    public class AddNewRecipeCommandSpecs
    {
        [TestMethod]
        public void When_creating_a_recipe_without_a_valid_title_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var executor = new BatchedCommandExecutorBuilder().Build();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => executor.Execute(new AddNewRecipeCommand
            {
                Title = "",
                Description = "Yummi"
            });

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldViolate(CookbookRule.RecipeTitleIsRequired);
        }
        
        [TestMethod]
        public void When_creating_a_recipe_without_a_valid_description_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var executor = new BatchedCommandExecutorBuilder().Build();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => executor.Execute(new AddNewRecipeCommand
            {
                Title = "Macaroni",
                Description = ""
            });

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldViolate(CookbookRule.RecipeDescriptionIsRequired);
        }
    }
}
